function UserInfoCtrl($scope, $http) {
	$("#basicInfoTab").on('click', function(e) {
		$("#PasswordTab").removeClass('active');
		$("#edit-password").removeClass('in active');
		$(this).addClass('active');
		$('#edit-basic').addClass('in active');
	});
	$("#PasswordTab").on('click', function(e) {
		$("#basicInfoTab").removeClass('active');
		$("#edit-basic").removeClass('in active');
		$(this).addClass('active');
		$('#edit-password').addClass('in active');
	});

	ajaxJSonPost("/YYOA/user/getUser", false, {
		"userName" : $scope.userName,
		"password" : $scope.password
	}, function(result) {
		$scope.userName = result.userName;
		$scope.name = result.name;
		if ("男" == result.sex) {
			$scope.sexChecked = true;
		} else {
			$scope.sexChecked = false;
		}

		$scope.describe = result.describe;
		$scope.email = result.email;
		$scope.phone = result.phone;
		$scope.mobilePhone = result.mobilePhone;
	}, null);

	$scope.sexChange = function(sexChange) {
		if (sexChange) {
			$scope.sexChecked = false;
		} else {
			$scope.sexChecked = true;
		}

	}
	$scope.save = function() {
		if ($("#basicInfoTab").hasClass('active')) {

			if ($scope.describe != null && $scope.describe.length > 300) {
				alert("描述文字不能超过300个字！");
			} else {
				var sex;
				if ($scope.sexChecked) {
					sex = "男";
				} else {
					sex = "女";
				}

				ajaxJSonPost("/YYOA/user/updateUser", true, {
					"userName" : $scope.userName,
					"name" : $scope.name,
					"sex" : sex,
					"describe" : $scope.describe,
					"email" : $scope.email,
					"phone" : $scope.phone,
					"mobilePhone" : $scope.mobilePhone
				}, function(result) {
					if (result) {
						alert("修改成功。");
					} else {
						alert("修改失败。");
					}
				}, null);
			}
		} else if ($("#PasswordTab").hasClass('active')) {
			if ($scope.newPw == null || $scope.newPw2 == null) {
				alert("密码不能为空，请重新输入！");
			} else if ($scope.newPw != $scope.newPw2) {
				alert("两次输入的密码不一样，请重新输入！");
			} else {
				ajaxJSonPost(
						"/YYOA/user/updateUserPw",
						true,
						{
							"userName" : $scope.userName,
							"password" : $scope.password,
							"newPassword" : $scope.newPw
						},
						function(result) {
							if (result) {
								alert("修改密码成功,请用新密码登录。");
								window.location.href = '/YYOA/pc/page/login/index.html';
							} else {
								alert("修改密码失败。");
							}
						}, null);
			}
		}
	}
}